﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using App.Interface;
using App.Model;
using Microsoft.Ajax.Utilities;
using Newtonsoft.Json;

namespace App.MVC.Controllers
{
    public class ZhiWeiConfigController : BaseController
    {
        // GET: ZhiWeiConfig
        public IZhiWu _IZhiWu { set; get; }
        public ActionResult Index()
        {
            return View();
        }

        public JsonResult GetZhiWuList()
        {
            var str = _IZhiWu.GetZhiWuList();
            List<ZhiWu> tt = JsonConvert.DeserializeObject<List<ZhiWu>>(str);
            return Json(tt, JsonRequestBehavior.AllowGet);
        }

        public void DelZhiWu(int zwid)
        {
            _IZhiWu.DelZhiWu(zwid);
        }

        public void SaveZhiWu(ZhiWu zhiwu)
        {
            if (zhiwu.zwid == 0)
            {
                _IZhiWu.SaveZhiWu(zhiwu);
            }
            else
            {
                _IZhiWu.UpdateZhiWu(zhiwu);
            }
        }
    }
}